package com.jiyang.jyandroid.bean;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by jy on 2016/11/18.
 * SpUtil
 */

public class SpUtil {
    private SharedPreferences sharedPreferences;

    public SpUtil(Context context) {
        sharedPreferences = context.getSharedPreferences("jy_shared", Context.MODE_PRIVATE);
    }

    public void saveDaily(Daily daily) {
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.putString("daily_title", daily.title).apply();
        editor.putString("daily_content", daily.content).apply();
        editor.putString("daily_time", daily.date).apply();
    }

    public Daily getDaily() {
        return new Daily(sharedPreferences.getString("daily_title", ""),
                sharedPreferences.getString("daily_content", ""),
                sharedPreferences.getString("daily_time", ""));
    }
}
